angular.module('todoApp',[])
  .controller('MyCtrl',['$scope',function ($scope) {
    $scope.todoList = [
      {name:'吃饭',checked:false}
      ,{name:'睡觉',checked:false}
      ,{name:'打豆豆',checked:false}
    ]
    //新增备忘录
    $scope.add = function () {
      //校验
      if (!$scope.newTodo){
        alert('输入的内容不能为空！')
        return;
      }
      //新增
      $scope.todoList.unshift({name:$scope.newTodo,checked: false})
      //清空输入框
      $scope.newTodo = ''
    }

    $scope.dele = function () {
      let oldList = []
      $scope.todoList.forEach(function (item, index) {
        if (!item.checked){
          oldList.push(item)
        }
      })
      $scope.todoList = oldList
    }
  }])